Optimal. Leaf size=139 \[ \frac {i a^3 d^2 (1-2 n) (d \cot (e+f x))^{-2+n}}{f (1-n) (2-n)}+\frac {d^2 (d \cot (e+f x))^{-2+n} \left (i a^3+a^3 \cot (e+f x)\right )}{f (1-n)}-\frac {4 i a^3 d^2 (d \cot (e+f x))^{-2+n} \, _2F_1(1,-2+n;-1+n;-i \cot (e+f x))}{f (2-n)} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.27, antiderivative size = 139, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 26, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.231, Rules used = {3754, 3637,
3673, 3618, 12, 66} \begin {gather*} -\frac {4 i a^3 d^2 (d \cot (e+f x))^{n-2} \, _2F_1(1,n-2;n-1;-i \cot (e+f x))}{f (2-n)}+\frac {d^2 \left (a^3 \cot (e+f x)+i a^3\right ) (d \cot (e+f x))^{n-2}}{f (1-n)}+\frac {i a^3 d^2 (1-2 n) (d \cot (e+f x))^{n-2}}{f (1-n) (2-n)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 66
Rule 3618
Rule 3637
Rule 3673
Rule 3754
Rubi steps
\begin {align*} \int (d \cot (e+f x))^n (a+i a \tan (e+f x))^3 \, dx &=d^3 \int (d \cot (e+f x))^{-3+n} (i a+a \cot (e+f x))^3 \, dx\\ &=\frac {d^2 (d \cot (e+f x))^{-2+n} \left (i a^3+a^3 \cot (e+f x)\right )}{f (1-n)}+\frac {\left (i a d^2\right ) \int (d \cot (e+f x))^{-3+n} (i a+a \cot (e+f x)) (i a d (3-2 n)+a d (1-2 n) \cot (e+f x)) \, dx}{1-n}\\ &=\frac {i a^3 d^2 (1-2 n) (d \cot (e+f x))^{-2+n}}{f (1-n) (2-n)}+\frac {d^2 (d \cot (e+f x))^{-2+n} \left (i a^3+a^3 \cot (e+f x)\right )}{f (1-n)}+\frac {\left (i a d^2\right ) \int (d \cot (e+f x))^{-3+n} \left (-4 a^2 d (1-n)+4 i a^2 d (1-n) \cot (e+f x)\right ) \, dx}{1-n}\\ &=\frac {i a^3 d^2 (1-2 n) (d \cot (e+f x))^{-2+n}}{f (1-n) (2-n)}+\frac {d^2 (d \cot (e+f x))^{-2+n} \left (i a^3+a^3 \cot (e+f x)\right )}{f (1-n)}-\frac {\left (16 a^5 d^4 (1-n)\right ) \text {Subst}\left (\int \frac {4^{3-n} \left (-\frac {i x}{a^2 (1-n)}\right )^{-3+n}}{-16 a^4 d^2 (1-n)^2-4 a^2 d (1-n) x} \, dx,x,4 i a^2 d (1-n) \cot (e+f x)\right )}{f}\\ &=\frac {i a^3 d^2 (1-2 n) (d \cot (e+f x))^{-2+n}}{f (1-n) (2-n)}+\frac {d^2 (d \cot (e+f x))^{-2+n} \left (i a^3+a^3 \cot (e+f x)\right )}{f (1-n)}-\frac {\left (4^{5-n} a^5 d^4 (1-n)\right ) \text {Subst}\left (\int \frac {\left (-\frac {i x}{a^2 (1-n)}\right )^{-3+n}}{-16 a^4 d^2 (1-n)^2-4 a^2 d (1-n) x} \, dx,x,4 i a^2 d (1-n) \cot (e+f x)\right )}{f}\\ &=\frac {i a^3 d^2 (1-2 n) (d \cot (e+f x))^{-2+n}}{f (1-n) (2-n)}+\frac {d^2 (d \cot (e+f x))^{-2+n} \left (i a^3+a^3 \cot (e+f x)\right )}{f (1-n)}-\frac {4 i a^3 d^2 (d \cot (e+f x))^{-2+n} \, _2F_1(1,-2+n;-1+n;-i \cot (e+f x))}{f (2-n)}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(925\) vs. \(2(139)=278\).
time = 8.36, size = 925, normalized size = 6.65 \begin {gather*} -\frac {4 i \left (1+e^{2 i (e+f x)}\right )^{-n} \left (\frac {i \left (1+e^{2 i (e+f x)}\right )}{-1+e^{2 i (e+f x)}}\right )^n \cos ^3(e+f x) \cot ^{-n}(e+f x) (d \cot (e+f x))^n \left (\left (1+e^{2 i (e+f x)}\right )^n \, _2F_1\left (1,-n;1-n;-\frac {-1+e^{2 i (e+f x)}}{1+e^{2 i (e+f x)}}\right )-2^n \, _2F_1\left (-n,-n;1-n;\frac {1}{2} \left (1-e^{2 i (e+f x)}\right )\right )\right ) (a+i a \tan (e+f x))^3}{\left (e^{i e}+e^{3 i e}\right ) f n (\cos (f x)+i \sin (f x))^3}-\frac {4 i e^{-3 i e} \left (-1+e^{2 i (e+f x)}\right )^{-n} \left (\frac {-1+e^{2 i (e+f x)}}{1+e^{2 i (e+f x)}}\right )^n \left (\frac {i \left (1+e^{2 i (e+f x)}\right )}{-1+e^{2 i (e+f x)}}\right )^n \cos ^3(e+f x) \cot ^{-n}(e+f x) (d \cot (e+f x))^n \left (\frac {\left (1+e^{2 i e}\right ) \left (-1+e^{2 i (e+f x)}\right ) \left (1+e^{2 i (e+f x)}\right )^{-1+n} \, _2F_1\left (1,1-n;2-n;\frac {1-e^{2 i (e+f x)}}{1+e^{2 i (e+f x)}}\right )}{-1+n}+\frac {\left (1+e^{2 i (e+f x)}\right )^n \, _2F_1\left (1,-n;1-n;\frac {1-e^{2 i (e+f x)}}{1+e^{2 i (e+f x)}}\right )}{n}-\frac {2^n \, _2F_1\left (-n,-n;1-n;\frac {1}{2} \left (1-e^{2 i (e+f x)}\right )\right )}{n}\right ) (a+i a \tan (e+f x))^3}{\left (1+e^{2 i e}\right ) f (\cos (f x)+i \sin (f x))^3}+\frac {\cos ^3(e+f x) (d \cot (e+f x))^n \left (\frac {(-3+2 n+\cos (2 e)) \sec ^2(e) \left (-\frac {1}{2} i \cos (3 e)-\frac {1}{2} \sin (3 e)\right )}{(-2+n) (-1+n)}+\frac {(-\cos (e-f x)+\cos (e+f x)) \sec ^2(e) \sec (e+f x) \left (\frac {1}{2} i \cos (3 e)+\frac {1}{2} \sin (3 e)\right )}{-1+n}+\frac {\sec ^2(e+f x) (i \cos (3 e)+\sin (3 e))}{-2+n}\right ) (a+i a \tan (e+f x))^3}{f (\cos (f x)+i \sin (f x))^3}+\frac {\cos ^3(e+f x) (d \cot (e+f x))^n \left (\frac {\sec ^2(e) (-1+\cos (2 e)+3 i \sin (2 e)) \left (-\frac {1}{2} i \cos (3 e)-\frac {1}{2} \sin (3 e)\right )}{-1+n}+\frac {\sec ^2(e) \sec (e+f x) \left (-\frac {1}{2} i \cos (3 e)-\frac {1}{2} \sin (3 e)\right ) (-\cos (e-f x)+\cos (e+f x)-3 i \sin (e-f x)+3 i \sin (e+f x))}{-1+n}\right ) (a+i a \tan (e+f x))^3}{f (\cos (f x)+i \sin (f x))^3} \end {gather*}
Warning: Unable to verify antiderivative.
[In]
[Out]
________________________________________________________________________________________
Maple [F]
time = 0.78, size = 0, normalized size = 0.00 \[\int \left (d \cot \left (f x +e \right )\right )^{n} \left (a +i a \tan \left (f x +e \right )\right )^{3}\, dx\]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Failed to integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} - i a^{3} \left (\int i \left (d \cot {\left (e + f x \right )}\right )^{n}\, dx + \int \left (- 3 \left (d \cot {\left (e + f x \right )}\right )^{n} \tan {\left (e + f x \right )}\right )\, dx + \int \left (d \cot {\left (e + f x \right )}\right )^{n} \tan ^{3}{\left (e + f x \right )}\, dx + \int \left (- 3 i \left (d \cot {\left (e + f x \right )}\right )^{n} \tan ^{2}{\left (e + f x \right )}\right )\, dx\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.01 \begin {gather*} \int {\left (d\,\mathrm {cot}\left (e+f\,x\right )\right )}^n\,{\left (a+a\,\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )}^3 \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________